2 Registering Jersey 2.5.1 (JAX-RS 2.0 Reference Implementation)

This chapter describes how to register and configure Jersey 2.5.1 Java API for RESTful Web Services (JAX-RS) 2.0 Reference Implementation (RI) for use with WebLogic Server 12.1.3.

This chapter includes the following sections:

About Registering Jersey 2.5.1 (JAX-RS 2.0 RI)

WebLogic Server ships with a pre-built shared library, packaged as a Web application, that is required to run applications that are based on Jersey 2.5.1 (JAX-RS 2.0 RI). To take advantage of Jersey 2.5.1 (JAX-RS 2.0 RI) features, you need to register the shared library and configure your Web applications, as described in the following sections:

Note:

RESTful web services and clients that are built using Jersey 2.5.1 (JAX-RS 2.0 RI) cannot be secured using Oracle Web Services Manager (OWSM) policies in this release.

Registering the Jersey 2.5.1 (JAX-RS 2.0 RI) Shared Library With Your WebLogic Server Instances

Shared Java EE libraries are registered with one or more WebLogic Server instances by deploying them to the target servers and indicating that the deployments are to be shared. Shared Java EE libraries must be targeted to the same WebLogic Server instances you want to deploy applications that reference the libraries.

When a referencing application is deployed, WebLogic Server merges the shared library files with the application. If you try to deploy a referencing application to a server instance that has not registered a required library, deployment of the referencing application fails.

The following sections describe how to register Jersey 2.5.1 (JAX-RS 2.0 RI) shared library with your WebLogic Server instances using the following tools:

Using the Administration Console

For each WebLogic Server instance to which you want to deploy Jersey 2.5.1 (JAX-RS 2.0 RI) applications, perform the following steps:

  1. Log into the WebLogic Server Administration Console as described in "Accessing Oracle WebLogic Administration Console" in Administering Web Services with Oracle Fusion Middleware.

    For example:

    http://host:port/console

  2. Select Deployments.

  3. Click Install to install the shared library.

  4. In the Path field, enter or navigate to the following directory: MW_HOME\wlserver\common\deployable-libraries.

  5. Select the jax-rs-2.0.war file.

  6. Click Next.

  7. Select Install this deployment as a library.

  8. Click Next.

  9. Click Finish.

Using WLST

For each WebLogic Server instance to which you want to deploy Jersey 2.5.1 (JAX-RS 2.0 RI) applications, perform the following steps:

  1. Invoke WLST, as described in "Invoking WLST" in Understanding the WebLogic Scripting Tool.

    For example:

    c:\Oracle\Middleware\wlserver\common\bin> wlst.cmd
    
  2. Connect to the running instance using the connect command.

    For example:

    wls:/offline> connect('weblogic', 'welcome1', 't3://localhost:7001')
    

    For more information, see "connect" in WLST Command Reference for WebLogic Server

  3. Deploy the shared library using the deploy command.

    For example:

    wls:/base_domain/serverConfig> deploy('jax-rs', 'c:\Oracle\Middleware\wlserver\common\deployable-libraries\jax-rs-2.0.war', libraryModule='true')
    

    For more information, see "deploy" in WLST Command Reference for WebLogic Server.

  4. Exit the WLST command session, as follows:

    wls:/base_domain/serverConfig> exit()
    

Using Ant

For each WebLogic Server instance to which you want to deploy Jersey 2.5.1 (JAX-RS 2.0 RI) applications, add an Ant task similar to the following to the build script:

<taskdef name="wldeploy" 
  classname="weblogic.ant.taskdefs.management.WLDeploy" />
<target name="deploy.jaxrs.2.0">
  <wldeploy action="deploy" 
    source="${mw.home}/wlserver/common/deployable-libraries/jax-rs-2.0.war"
    name="jax-rs" user="${user}" password="${passwd}" 
    adminurl="t3://${webServerHost}:${webServerPort}"
    verbose="true" targets="myserver" library="true" />
</target>

Using weblogic.Deployer

For each WebLogic Server instance for which you want to deploy JAX-RS 2.5.1 applications, use weblogic.Deployer to deploy the shared library files to the required target servers, and identify the deployment as a library using the -library option.

The following shows an example of how to deploy the Jersey 2.5.1 (JAX-RS 2.0 RI) shared library using weblogic.Deployer:

java weblogic.Deployer -verbose -noexit -source C:\Oracle\Middleware\wlserver\common\deployable-libraries\jax-rs-2.0.war -targets myserver -adminurl t3://localhost:7001 -user weblogic -password ******** -deploy -library

Configuring the Web Application to Use Jersey 2.5.1 (JAX-RS 2.0 RI)

You need to configure the Web application that contains the RESTful web services to use the Jersey shared libraries. Specifically, you need to update the weblogic.xml deployment descriptor files that are associated with your application to reference the shared library. The weblogic.xml file is located in the WEB-INF directory in the root directory of your application archive.

The following example shows how to update the weblogic.xml file to use Jersey 2.5.1 (JAX-RS 2.0 RI).

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app 
           http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">
 
    <wls:library-ref>
       <library-name>jax-rs</library-name>
       <specification-version>2.0</specification-version>
       <exact-match>false</exact-match>
    </wls:library-ref>
</wls:weblogic-web-app>